package think.in.java.concurrency.practise.exec6;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by IntelliJ IDEA.
 * User: Richard
 * Date: 5/19/11
 * Time: 9:00 PM
 * To change this template use File | Settings | File Templates.
 */
public class EvenGeneratorForSync extends IntGenerate{
    private int currentValue = 0;

    @Override
    //this class can't be fix by using the volatile , as there will be many method access this method ,
    //but the increase number will be less , as we use the volatile for the int
    //and if we use AtomicInteger the increase will less more
    public synchronized int next() {
        currentValue++;
        currentValue++;
        return currentValue;
    }

}
